"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
const redux_1 = require("@tarojs/redux");
const taro_1 = require("@tarojs/taro");
const taro_ui_1 = require("taro-ui");
const components_1 = require("@tarojs/components");
const YContentPadded_1 = require("../../components/YContentPadded");
const goods_1 = require("../../actions/goods");
require("./Integrals.scss");
let GoodsIntegrals = class GoodsIntegrals extends taro_1.Component {
    constructor() {
        super(...arguments);
        this.config = {
            navigationBarTitleText: '种草排行',
            enablePullDownRefresh: true,
            backgroundColor: '#ccc'
        };
        this.state = {
            isOpened: false
        };
        this.onClick = (msg) => {
            console.log(msg, 123);
        };
    }
    componentWillMount() {
        if (this.props.goods.profile.data) {
            this.props.fetchIntegrals({ id: this.props.goods.profile.data.id }, (msg) => {
                // console.log(msg, 'fetchUsers')
            });
        }
    }
    onPullDownRefresh() {
        console.log('--------下拉刷新-------');
        taro_1.default.showNavigationBarLoading(); //在标题栏中显示加载
        setTimeout(() => {
            // complete
            taro_1.default.hideNavigationBarLoading(); //完成停止加载
            taro_1.default.stopPullDownRefresh(); //停止下拉刷新
        }, 2000);
    }
    onReachBottom() {
        this.setState(state => (Object.assign({}, state, { isOpened: true })));
        console.log('--------上拉刷新-------');
        setTimeout(() => {
            taro_1.default.stopPullDownRefresh(); //停止下拉刷新
            this.setState(state => (Object.assign({}, state, { isOpened: false })));
        }, 2000);
    }
    render() {
        return (<components_1.View className='GoodsUserProfile'>
        <taro_ui_1.AtToast isOpened={this.state.isOpened} text='加载中...' status='loading' hasMask={true}/>
        
        <YContentPadded_1.default>
          <taro_ui_1.AtList>
            {this.props.goods.integralIns.data && this.props.goods.integralIns.data.map((item) => (<taro_ui_1.AtListItem key={item.id} thumb={item.avatarUrl} extraThumb={item.avatarUrl} extraText={'+' + item.Integrals.length} note={item.updatedAt} title={item.nickname}/>))}
            {this.props.goods.integralIns.data && this.props.goods.integralIns.data.length === 0 &&
            <components_1.View style={{ textAlign: 'center' }}><components_1.Text style={{ fontSize: 32 }}>暂无</components_1.Text></components_1.View>}
          </taro_ui_1.AtList>
        </YContentPadded_1.default>       
      </components_1.View>);
    }
};
GoodsIntegrals = __decorate([
    redux_1.connect(({ goods }) => ({
        goods
    }), (dispatch) => ({
        fetchIntegrals(params, callback) {
            dispatch(goods_1.queryIntegrals(params, callback));
        }
    }))
], GoodsIntegrals);
exports.default = GoodsIntegrals;
//# sourceMappingURL=Integrals.jsx.map